def cell_division_2(n):
    cell=[]
    for i in range(51):
        cell.append(0)
    cell[1]=1
    cell[2]=1
    cell[3]=1
    index=4
    while index<n+1:
        cell[index]=cell[index-1]+cell[index-3]
        index+=1
    return cell[n]

if __name__=="__main__":
    while True:
        n=int(input().strip())
        if n==0:
            break
        print(cell_division_2(n))